import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    username:'',
    token:''
  },
  mutations: {
    setUserName(state,name){
      state.username=name;
    },
    delUserName(state){
      state.username=''
    },
    setToken(state,token){
      state.token=token;
    },
    delToken(state){
      state.token=''
    }
  },
  actions: {
    setUserNameAction(context,name){
      context.commit('setUserName',name)
    },
    delUserNameAction(context){
      context.commit('delUserName')
    },
    setTokenAction(context,token){
      context.commit('setToken',token)
    },
    delTokenAction(context){
      context.commit('delToken')
    }
  },
  modules: {
  }
})
